const utils =require('./utils/index')
const HtmlPlugin = require('html-webpack-plugin');
const config = {
    entry: {
        popup: ["./src/popup/index.tsx"],  //入口文件,
    },
    output: {},
    watchOptions: {
        ignored: utils.resolve('/node_modules'),//忽略文件
    },
    devtool: 'eval',
    resolve: { extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js'] },
    module: {
        rules: [{ 
            test: /\.tsx?$/, 
            loader: 'ts-loader',
            options: {
                configFile: utils.resolve('/config/tsconfig.json')
    　　　　　}
            },
            {
                test: /\.less$/,
                use: ['style-loader', 'css-loader', 'less-loader']
            }
        ]
    },
    plugins: [//插件， 会在 loader后执行
        new HtmlPlugin({
            minify: {
                removeAttributeQuotes: true    //去除属性引号。。。
            },
            hash: true,  //js缓存去除
            template: './public/index.html'
        }),
        utils.getPage({
            name: 'popup',
            template: './public/index.html'
        }),
    ],
    devServer: {
        contentBase: utils.resolve('/dist'),        //配置要监听的目录，使用绝对路径
        host: "localhost",//服务器地址
        port:9090,
        historyApiFallback: true,//不跳转
        inline: true,//实时刷新
    }
}

module.exports = config